﻿#region Creditos

/* Autor: Edilberto Sánchez Forero	*/
/* Email: esanchezfo@gmail.com		*/
/* Licencia: LGPL, Software Libre	*/
/* País: Colombia, Bogotá			*/

#endregion

#region Librerias

using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using ESF.General;

#endregion


namespace ESF.Object.XmlRepresenter.Extensions.Description
{
	public class XmlMemberDescription :  IEquatable<XmlMemberDescription>
	{
		#region Miembros
		
		private string _Label;
		private string _Example;
		private string _Description;
		private string _ISOLanguageCode;
		private string _MemberName;
		private string _ObjectName;
		
		private bool _Default;
		
		#endregion
		
		
		#region Propiedades
		
		public string ObjectName { get { return this._ObjectName; } }
		
		public string MemberName { get { return this._MemberName; } }
		
		public string Label { get { return this._Label; } set { this._Label = value; } }
		
		public string Example { get { return this._Example; } }
		
		public string Description { get { return this._Description; } set { this._Description = value; } }
		
		public string ISOLanguageCode { get { return this._ISOLanguageCode; } }
		
		public bool Default { get { return this._Default; } }
		
		#endregion
		
		
		#region Constructor

		public XmlMemberDescription (string pstrMemberName)
		{
			this._MemberName = pstrMemberName;
			this._Label = pstrMemberName;
			this._ISOLanguageCode = "en";
			this._Default = true;
		}


		public XmlMemberDescription (ref XmlTextReader pxmlReader, string pstrObjectName, bool pblnDefault, string pstrISOLanguageCode)
		{
			XmlHelper xmlEx;
			
		
			xmlEx = new XmlHelper ();
			xmlEx.ObjectName = string.Format ("Descripción del Miembro {0}.{1}", pstrObjectName, pxmlReader.Name);
			xmlEx.EvaluatedNodeReader = pxmlReader;
			
			this._ObjectName = pstrObjectName;
			this._MemberName = pxmlReader.Name;
			
			this._ISOLanguageCode = pstrISOLanguageCode;
			
			this._Label = xmlEx.GetAttributeValue (false, "label", "Etiqueta"); 
			this._Description = xmlEx.GetAttributeValue (false, "description", "Descripción");
			this._Example = xmlEx.GetAttributeValue (false, "example", "Ejemplo");
			
			this._Default = pblnDefault;
		}

		#endregion	
	

		#region IEquatable<XmlMemberDescription> Members

		public bool Equals(XmlMemberDescription pobjOtherDescription)
		{
			return (pobjOtherDescription.ISOLanguageCode == this.ISOLanguageCode && 
				pobjOtherDescription.MemberName == this.MemberName && 
				pobjOtherDescription.ObjectName == this._ObjectName);
		}

		#endregion
	}
}